package Function.ItemUse;

import FCRendering.FCRBattleOrderConstant;
import VWorldGameStudio.*;

import static FCRendering.FCRMaster.fcv;

public class ToolPenWuJi extends AItemUse{
    @Override
    public ItemUseResult directUse() {
        return useForPlayerTarget(keepPlayer);
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        return useForPlayerTarget(keepPlayer);
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        fcv.closeAllShowWindw();
        if(p.isDeath()){
            fcv.getMessage().add("不能给死者使用,什么也没发生");
            fcv.showMessage();
            return new ItemUseResult().useless();
        }
        if(fcv.isBattle()) {
            FCPlayerBattleWrap wrap = FCPlayerBattleWrap.findBattleWrapByName(p.getAliasUID(), p.getName());
            int isFire = wrap.getLongTermVal(FCRBattleOrderConstant.S_Acid);
            if (isFire != -1) {
                wrap.removeLongTermState(FCRBattleOrderConstant.S_Acid);
                fcv.getMessage().add("将" + p.getChName()+"身上的酸中和了");
                fcv.showMessage();
            } else {
                fcv.getMessage().add(p.getChName() + "没中酸，什么也没发生");
                fcv.showMessage();
            }
        }else {
            FCLongTermState state = p.getLongTermMap().get(FCRBattleOrderConstant.S_Acid);
            if (state != null) {
                p.getLongTermMap().remove(FCRBattleOrderConstant.S_Acid);
                fcv.getMessage().add("将" + p.getChName()+"身上的酸中和了");
                fcv.showMessage();
            } else {
                fcv.getMessage().add(p.getChName() + "没中酸，什么也没发生");
                fcv.showMessage();
            }
        }
        return new ItemUseResult();
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        return useForPlayerTarget(keepPlayer);
    }
}
